package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.CampCommunication;
import com.ruoyi.wechat.service.ICampCommunicationService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 营地交流Controller
 *
 * @author ruoyi
 * @date 2024-12-25
 */
@Api(value = "微信小程序API-营地动态", tags = {"微信小程序API-营地动态"})
@RestController
@RequestMapping("/wechat/communication")
public class WxCampCommunicationController extends BaseController {

    @Autowired
    private ICampCommunicationService campCommunicationService;

    /**
     * 查询营地交流列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CampCommunication campCommunication)
    {
        startPage();
        List<CampCommunication> list = campCommunicationService.selectCampCommunicationList(campCommunication);
        return getDataTable(list);
    }

    /**
     * 获取营地交流详细信息
     */
    @GetMapping(value = "/{campcommunicationId}")
    public AjaxResult getInfo(@PathVariable("campcommunicationId") String campcommunicationId)
    {
        return success(campCommunicationService.selectCampCommunicationByCampcommunicationId(campcommunicationId));
    }

    /**
     * 新增营地交流
     */
    @Log(title = "营地动态", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CampCommunication campCommunication)
    {
//        System.out.print("campCommunication::::" + campCommunication);
        return success(campCommunicationService.insertCampCommunicationImage(campCommunication));
    }

    /**
     * 修改营地交流
     */
    @Log(title = "营地交流", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CampCommunication campCommunication)
    {
        return toAjax(campCommunicationService.updateCampCommunication(campCommunication));
    }

    /**
     * 删除营地交流
     */
    @Log(title = "营地交流", businessType = BusinessType.DELETE)
    @DeleteMapping("/{campcommunicationIds}")
    public AjaxResult remove(@PathVariable String[] campcommunicationIds)
    {
        return toAjax(campCommunicationService.deleteCampCommunicationByCampcommunicationIds(campcommunicationIds));
    }

    /**
     * 根据用户ID查询租赁订单及关联产品订单信息
     * @return 包含租赁订单和关联产品订单信息的列表
     */
    @GetMapping("/getCampCommunicaTionList")
    public AjaxResult  getCampCommunicaTionList(CampCommunication campCommunication) {
        System.out.print("campCommunication" + campCommunication);
        return success(campCommunicationService.getCampCommunicaTionList(campCommunication));
    }

    /**
     * 取消营地动态
     */
    @Log(title = "取消赁订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/campcommunicationId/{campcommunicationId}")
    public AjaxResult campCommunicaTionRemove(@PathVariable("campcommunicationId") String campcommunicationId)
    {
        return toAjax(campCommunicationService.deleteCampCommunicationByCampcommunicationId(campcommunicationId));
    }
}
